package net.sxnic.workflow.conf;

import java.util.Set;

import org.apache.commons.lang.StringUtils;

/**
 * 工作流转工具类
 * 
 * @author 孙宇飞
 * 
 */
public class WfConfigUtils {

	private static WfConfigUtilsInterface wfc;

	public static WfConfigUtilsInterface getUtils(String cate) {

		if (wfc != null) {
			return wfc;
		}

		if (StringUtils.isBlank(cate)) {
			wfc = new WfConfigUtilsFileImpl();
			return wfc;
		} else {
			wfc = new WfConfigUtilsDbImpl();
			return wfc;
		}
	}

	public static String findValidateDef(String processName, String nodeName) throws Exception {
		return getUtils("").findValidateDef(processName, nodeName);
	}

	public static String findAssigneeDef(String processName, String nodeName) throws Exception {
		return getUtils("").findAssigneeDef(processName, nodeName);
	}

	public static Set<String> findNextNodes(String processName, String nodeName) throws Exception {
		return getUtils("").findNextNodes(processName, nodeName);
	}

	public static String findStartNodeName(String processName) throws Exception {
		return getUtils("").findStartNodeName(processName);
	}

	public static String findJSP(String processName, String nodeName) throws Exception {
		return getUtils("").findJSP(processName, nodeName);
	}

	public static Set<String> findHandlers(String processName, String nodeName, String action) throws Exception {
		return getUtils("").findHandlers(processName, nodeName, action);
	}

	public static String getNextAssigneeByProcessNode(String processName, String currNodeName) throws Exception {
		return getUtils("file").getNextAssigneeByProcessNode(processName, currNodeName);
	}

	public static String[] getAssigneeArrayByProcessNode(String processName, String nodeName) throws Exception {
		return getUtils("file").getAssigneeArrayByProcessNode(processName, nodeName);
	}

}
